home *** CD-ROM | disk | FTP | other *** search
/ CICA 1993 April / CICA MS Windows - April 1993.iso / unzipped / util / enhpcp1 / decom.was next >
Text File  |  1992-12-01  |  2KB  |  51 lines

  1. ;"DeCom" - Script to de-comment scripts
  2.  
  3. ;When I began to comment my scripts, I found that my comments almost always
  4. ;carried the lines to more than 80 characters, making printouts almost
  5. ;impossible to read (I like to work on my scripts while I'm riding the bus).
  6. ;This script will de-comment another script file.  It will not remove
  7. ;#comment-#endcomment blocks, only those lines containing a ";" will
  8. ;be affected.
  9.  
  10. ;please send any comments, criticisms, complaints, praises, donations (haha), etc. to
  11. ;Erick Hammersmark, ehammers@u.washington.edu
  12.  
  13. string OldLine,NewLine,InFile,OutFile,LineString = "Line 0"
  14. integer lines,selection,index
  15.  
  16. proc main
  17.  sdlgfopen "Input File" "c:\prowin\aspect\*.was" InFile        ;select input file
  18.  if not success
  19.   exit
  20.  endif
  21.  fopen 0 InFile READ TEXT                    ;open input file
  22.  sdlgsaveas "Output File" "c:\prowin\aspect\*.was" OutFile    ;select output file
  23.  if not success
  24.   exit
  25.  endif
  26.  fopen 1 OutFile CREATE TEXT                    ;create output file
  27.  dialogbox 161 128 133 50 3 "Converting"
  28.   vtext 33 19 66 9 center LineString
  29.  enddialog
  30.  while 1
  31.   fgets 0 OldLine                        ;read line from input file
  32.   inc lines                            ;increase "lines" by one
  33.   strfmt LineString "Line %d" lines                ;display new value for "lines"
  34.   updatedlg 64
  35.   strfind OldLine ";" index                    ;locate comment
  36.   if Found                            ;if there's a comment
  37.    strcpy NewLine OldLine index                    ;copy only everything before the comment to NewLine
  38.   else                                ;else
  39.    NewLine = OldLine                        ;copy everything to NewLine
  40.   endif
  41.   fputs 1 NewLine                        ;write NewLine to output file
  42.   if feof 0                            ;if at the end of input file
  43.    exitwhile                            ;exit loop
  44.   endif
  45.  endwhile
  46.  destroydlg
  47.  fclose 0
  48.  fclose 1
  49.  sdlgmsgbox "Done!" "Conversion complete." INFORMATION OK selection 1
  50. endproc
  51.